#ifndef _PROTOCOL_PARSER_HPP_20120513
#define _PROTOCOL_PARSER_HPP_20120513

#include "base.hpp"

#include "listbuffer.hpp"
#include "abstract_parser.hpp"

using namespace mina;

namespace protocol
{
	class Protocol;

	class ProtocolParser : public AbstractParser
	{
		public :
			virtual int encode(ListBuffer & listbuffer, void * data);
			
			virtual int  decode(ListBuffer & listbuffer, void *& data);

			bool frame(ListBuffer & listbuffer);
		
		public :	
			static uint32_t get_magic(ListBuffer & listbuffer);
			static uint32_t get_length(ListBuffer & listbuffer);
			static uint16_t get_cmd0(ListBuffer & listbuffer);
			static uint16_t get_cmd1(ListBuffer & listbuffer);
		
		public :
			const static uint32_t MAX_PROTOCOL_SIZE = 1024 * 1024;

            char _buffer[MAX_PROTOCOL_SIZE];
	};
};

#endif

